package CYClassDemo;

public class MathDemo {
    public static void main(String[] args) {
        int i = getMax(1,2);
        System.out.println(i);

        //使用math获取两个数字中的最大值
        int max = Math.max(1, 3);
        System.out.println(max);

        //获取两个数中的最小值
        int min = Math.min(2, 4);
        System.out.println(min);


        //返回参数的绝对值
        int abs = Math.abs(-1);
        System.out.println(abs);

        //向上取整
        double ceil = Math.ceil(3.9);
        double ceil1 = Math.ceil(1.2);
        System.out.println(ceil);
        System.out.println(ceil1);
        //向下取整
        double floor = Math.floor(1.9);
        System.out.println(floor);
        double floor1 = Math.floor(2.1);
        System.out.println(floor1);
        //开平方
        double sqrt = Math.sqrt(9);
        System.out.println(sqrt);
        //四舍五入
        long round = Math.round(4.5);
        System.out.println(round);
        long round1 = Math.round(4.4);
        System.out.println(round1);
        long round2 = Math.round(4.6);
        System.out.println(round2);

    }
    public static int getMax(int i,int j){
        if (i>=j){
            return i;
        }else{
            return j;
        }

    }
}
